package com.example.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.gen2.client.SliderBarVertical;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DoubleBox;
import com.google.gwt.user.client.ui.RequiresResize;
import com.google.gwt.user.client.ui.Widget;

public class SliderTest extends Composite implements RequiresResize {

  interface SliderTestUiBinder extends UiBinder<Widget, SliderTest> {
  }

  private static SliderTestUiBinder uiBinder = GWT
      .create(SliderTestUiBinder.class);

  @UiField
  protected SliderBarVertical sliderVertical;
  @UiField
  protected DoubleBox doubleBox;

  public SliderTest() {
    initWidget(uiBinder.createAndBindUi(this));

    sliderVertical.addValueChangeHandler(new ValueChangeHandler<Double>() {

      @Override
      public void onValueChange(final ValueChangeEvent<Double> event) {
        doubleBox.setValue(event.getValue());
      }
    });

  }

  @Override
  public void onResize() {
    sliderVertical.onResize();
  }

}
